#include <iostream>
#include <cmath>

bool primer(int num) {
    if (num < 2) {
        return false;
    }
    for (int i = 2; i <= static_cast<int>(std::sqrt(num)) + 1; i++) {
        if (num % i == 0) {
            return false;
        }
    }
    return true;
}

int next_prime(int num) {
    while (true) {
        num++;
        if (primer(num)) {
            return num;
        }
    }
}

int main() {
    std::string input;
    std::getline(std::cin, input);
    std::string number_str = "";
    for (const auto& word : split(input, ' ')) {
        if (word == "zero") {
            number_str += "0";
        } else if (word == "one") {
            number_str += "1";
        } else if (word == "two") {
            number_str += "2";
        } else if (word == "three") {
            number_str += "3";
        } else if (word == "four") {
            number_str += "4";
        } else if (word == "five") {
            number_str += "5";
        } else if (word == "six") {
            number_str += "6";
        } else if (word == "seven") {
            number_str += "7";
        } else if (word == "eight") {
            number_str += "8";
        } else if (word == "nine") {
            number_str += "9";
        } else if (word == "1" || word == "2" || word == "3" || word == "4" || word == "5" || word == "6" || word == "7" || word == "8" || word == "9") {
            std::cout << "Wrong input" << std::endl;
        }
    }
    int num = std::stoi(number_str);
    std::cout << next_prime(num) << std::endl;
    return 0;
}

